package com.laoniu.dto;

import java.util.Date;

public class RestResult {

    private Integer code;

    private String message;

    private Date requestTime;

    private Object data;

    public RestResult(){
        this.requestTime = new Date();
    }

    public RestResult(Integer code, String message, Object data){
        this.requestTime = new Date();
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static RestResult success(){
        return new RestResult(200,"操作成功", null);
    }

    public static RestResult success(Object data){
        return new RestResult(200,"操作成功", data);
    }

    public static RestResult fail(){
        return new RestResult(500, "操作失败", null);
    }

    public static RestResult fail(String message){
        return new RestResult(500, message, null);
    }

    public static RestResult fail(Integer code, String message){
        return new RestResult(code, message, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Date getRequestTime() {
        return requestTime;
    }

    public void setRequestTime(Date requestTime) {
        this.requestTime = requestTime;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
